using System.IO;
using System.Windows.Markup;

namespace Rhizome.Core.XNA.WP.Xaml
{
	public static class XamlExtension
	{
		public static T LoadXaml<T>(string fileName)
		{
			string s;
			using (var reader = File.OpenText(fileName))
			{
				s = reader.ReadToEnd();
			}

			return (T) XamlReader.Load(s);
		}

		public static T LoadXaml<T>(this Stream stream)
		{
			string s;
			using (var reader = new StreamReader(stream))
			{
				s = reader.ReadToEnd();
			}
			return (T) XamlReader.Load(s);
		}
	}
}